import java.util.Scanner;

public class Class1 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String s= scanner.next();
        if (s.length()<6){
            System.out.println(0);
            return;
        }
        int[] char_map = new int[26];
        for (int i=0;i<s.length();i++){
            char c= s.charAt(i);
            char_map[c-'a']++;
        }
        int num_a = char_map[0];
        int num_b = char_map[1];
        int num_c = char_map[2];
        int res = 0;
        int a = num_a/2 +num_a%2;
        int b = num_b;
        int c = num_c/3;
        if (num_a<2||num_b<1||num_c<3){
            System.out.println(0);
            return;
        }
        res = Math.min(a,b);
        System.out.println(Math.min(res,c));


    }
}
